/**
 * @author徐航
 * 红包界面
 */
cc.Class({
    extends: cc.Component,
    properties: {
        redBagText: cc.RichText,
        newPeople: cc.Node,
        descText: cc.Label,
        closeBtn: cc.Button,
    },

    start() {

    },

    show() {
        this.descText.active = true;
        this.newPeople.active = false;
        this.closeBtn.active = false;
        var redBagNumr = Math.random() * 25 + 25;
        //this.redBagText.string = '<b>+' + this.toDecimal2(redBagNumr) + '<size=40>元</size></b>';
        this.redBagText.string = '+' + this.toDecimal2(redBagNumr) + '<b><size=40>元</size></b>'
    },

    setNewPeopleRed() {
        this.newPeople.active = true;
        this.closeBtn.active = false;
        this.descText.active = false;
    },

    toDecimal2(x) {
        var f = parseFloat(x);
        if(isNaN(f)) {
            return false;
        }
        var f = Math.round(x * 100) / 100;
        var s = f.toString();
        var rs = s.indexOf('.');
        if(rs < 0) {
            rs = s.length;
            s += '.';
        }
        while(s.length <= rs + 2) {
            s += '0';
        }
        return s;
    }
})